package com.extension.company.view.home.message;

import android.app.Activity;
import android.content.Intent;
import android.view.View;

import com.extension.company.admin.R;
import com.extension.company.common.mvp.BaseTitleActivity;
import com.extension.company.contract.MessCenterListContract;
import com.extension.company.model.entity.MessCenterListData;
import com.extension.company.presenter.home.MessCenterListPresenter;
import com.extension.company.view.adapter.MessCenterListAdapter;
import com.extension.company.view.adapter.OnRecyclerViewClickListener;
import com.extension.company.common.widget.PullRefreshRecyclerView;

import java.util.List;

import butterknife.BindView;

/**
 * create zwk
 * data   2019/2/19
 * 描述：fragmentHome中 消息中心
 */
public class MessCenterListActivity extends BaseTitleActivity<MessCenterListContract.View, MessCenterListPresenter>
		implements MessCenterListContract.View {

	@BindView(R.id.mRecyclerView)
	PullRefreshRecyclerView mRecyclerView;

	private List<MessCenterListData> list;
	private MessCenterListAdapter adapter;

	public static void startMessCenterList(Activity activity) {
		Intent intent = new Intent(activity, MessCenterListActivity.class);
		activity.startActivity(intent);
	}

	@Override
	public int getMainLayout() {
		return R.layout.base_recyclerview;
	}

	@Override
	protected void initData() {
		setTitle("消息中心");
		mRecyclerView.setLinearLayout();
		adapter = new MessCenterListAdapter(this, list);
		mRecyclerView.setAdapter(adapter);
		if (presenter != null) {
			presenter.getData();
		}
	}

	@Override
	protected void initListener() {
		mRecyclerView_OnClickListener();
	}

	private void mRecyclerView_OnClickListener() {
		adapter.setOnClickListener(new OnRecyclerViewClickListener() {
			@Override
			public void onItemClick(View view, int position) {
//				MessCenterListDetils.startActivity(MessCenterListActivity.this, Urls.MessDetilsUrl,
//						"123");
				int type = 0;
				switch (position) {
					case 0:
						type = 0;
						Intent intent = new Intent(MessCenterListActivity.this, MessageDetailActivity.class);
						intent.putExtra("id", type);
						startActivity(intent);
						break;
					case 1:
						type = 1;
						Intent intent1 = new Intent(MessCenterListActivity.this, MessageDetailActivity.class);
						intent1.putExtra("id", type);
						startActivity(intent1);
						break;

					case 2:
						type = 2;
						Intent intent2 = new Intent(MessCenterListActivity.this, MessageDetailActivity.class);
						intent2.putExtra("id", type);
						startActivity(intent2);
						break;
					default:

						break;
				}
			}

			@Override
			public void onItemLongClick(View view, int position) {

			}
		});
	}

	@Override
	public MessCenterListContract.View createView() {
		return this;
	}

	@Override
	public MessCenterListPresenter createPresenter() {
		return new MessCenterListPresenter();
	}

	@Override
	public void showLoading() {

	}

	@Override
	public void hideLoading() {

	}

	@Override
	public void onError(Throwable throwable) {

	}
}
